﻿using System;

namespace Froggy.Stocks
{
    public class Quotation : IQuotationSnapshot
    {
        public Quotation(Stock stock, DateTime date, IQuotationSnapshot previous, double openValue, double closeValue, double maxValue, double minValue, double volume)
        {
            _WeekOfYear = Convert.ToInt32(Math.Ceiling(date.DayOfYear / 7.0));
            _Month = date.Month;
            _Year = date.Year;
            _Date = date;
            _Stock = stock;
            _Previous = previous;
            _OpenValue = openValue;
            _CloseValue = closeValue;
            _MaxValue = maxValue;
            _MinValue = minValue;
            _Volume = volume;
            _Candle = new Candle(this);
        }

        private readonly Stock _Stock;
        private readonly int _Year;
        private readonly int _Month;
        private readonly int _WeekOfYear;
        private readonly DateTime _Date;
        private readonly IQuotationSnapshot _Previous;
        private readonly double _OpenValue;
        private readonly double _CloseValue;
        private readonly double _MaxValue;
        private readonly double _MinValue;
        private readonly double _Volume;
        private readonly Candle _Candle;

        public Stock Stock
        {
            get { return _Stock; }
        }

        public DateTime Date
        {
            get { return _Date; }
        }

        public int Year
        {
            get { return _Year; }
        }

        public int Month
        {
            get { return _Month; }
        }

        public int WeekOfYear
        {
            get { return _WeekOfYear; }
        }

        IQuotationSnapshot IQuotationSnapshot.Previous
        {
            get { return this.Previous; }
        }

        public IQuotationSnapshot Previous
        {
            get { return _Previous; }
        }

        public double OpenValue
        {
            get { return _OpenValue; }
        }

        public double CloseValue
        {
            get { return _CloseValue; }
        }

        public double MaxValue
        {
            get { return _MaxValue; }
        }

        public double MinValue
        {
            get { return _MinValue; }
        }

        public double Volume
        {
            get { return _Volume; }
        }

        public Candle Candle
        {
            get { return _Candle; }
        }
    }
}